--
-- @Author:      name
-- @DateTime:    2018-03-30 23:05:48
-- @Description: 消息的处理

local skynet = require "skynet"
local config = require "configquery"
local NodeMessage = require "NodeMessage"


local MessageHandler = class("MessageHandler")

---------------------------------------------------------
-- Private
---------------------------------------------------------
function MessageHandler:ctor(message_dispatch)
	self.message_dispatch = message_dispatch
	self.node_message = NodeMessage.new()		
	self:register()
	--清除socket
	-- skynet.fork(function()
	-- 	self:loop()
	-- end)	
end

--注册本服务里的消息
function MessageHandler:register()

	self.message_dispatch:registerSelf('start',handler(self,self.start))

end


---------------------------------------------------------
-- CMD
---------------------------------------------------------
function MessageHandler:start()

	print("__manager__start")
	
	--skynet控制台
	-- skynet.newservice("debug_console",svr_config.debug_port)

	-- --数据库
 -- 	self.node_message:callProxy("dbserver","load_tables",{{name="users", pk='id',key='name' },})	

 	local user_list = {
 		{
 			account = "test9",
 			password = "123456",
 		},
 		-- {
 		-- 	account = "test10",
 		-- 	password = "123456",
 		-- }, 		
 	}
	--socket消息处理
	local service
	for i = 1, #user_list do
		service = skynet.newservice("robot_service")		
		skynet.call(service, 'lua', 'start', user_list[i])
		-- skynet.sleep(300)
	end

	
end





return MessageHandler